<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE root PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core">

	<h:outputText rendered="#{pontoBean.saveImportarPontoState}">
		<div class="innerTitle">Importação de Pontos</div>
	</h:outputText>

	<h:outputLabel value="Parametros de configuração do arquivo:" style="font-size: 12pt; font-weight:bold; color: green;"/>
	<rich:menuSeparator/>

	<table>
		<tr>
			<td>
				<h:outputLabel value="Cliente :"/>
				<h:selectOneMenu id="clienteVeiculo" value="#{pontoBean.cliente}" immediate="true">
		  			<f:selectItems value="#{clienteBean.listaClientes}"/>
		  			<a4j:support event="onchange" action="#{pontoBean.populate}" reRender="clienteVeiculo"/>
				</h:selectOneMenu>
				<rich:message for="clienteVeiculo"/>
			</td>
			<td>
				<h:outputLabel value="Tipo do Arquivo:"/>
				<h:selectOneMenu id="tipoArquivo" value="#{pontoBean.tipoArquivo}" required="true" immediate="true" styleClass="filesRoute" style="width:60px">
					<f:selectItems value="#{rotaBean.typeFile}"/>
					<a4j:support event="onchange" action="#{pontoBean.populate}" reRender="tipoArquivo"/>
				</h:selectOneMenu>
			</td>
			<td>
				<h:outputLabel value="Separador: " style="padding-left: 10px"/>
				<h:selectOneMenu id="caracterSeperador" value="#{pontoBean.formato.tipoSeparador}" immediate="true" style="width:75px">
		 			<f:selectItems value="#{pontoBean.separador}"/>
		 			<a4j:support event="onchange" action="#{pontoBean.populate}" reRender="caracterSeperador"/>
				</h:selectOneMenu>
				<rich:message errorClass="error" for="caracterSeperador" />		 			
	 		</td>
	 	</tr>

	 	<tr>
	 		<td>
				<h:outputLabel value="Caracteres de início: "/>
				<h:inputText id="caractereInicio" value="#{pontoBean.formato.caractereInicio}" maxlength="16" size="16">
					<f:validateLength maximum="16" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="caractereInicio" />	 		
	 		</td>
		</tr>
		<tr>
	 		<td>
				<h:outputLabel value="Caracteres de Fim:   "/>
				<h:inputText id="caracteresFim" value="#{pontoBean.formato.caractereFim}" maxlength="16" size="16">
					<f:validateLength maximum="16" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="caracteresFim" />	 		
	 		</td>
	 		<td>
				<h:outputText styleClass="text" value="Não possui caracteres de controle: " style="color:blue; font-size:10pt"/>
				<h:selectBooleanCheckbox id="notControlFile" styleClass="none" value="#{pontoBean.notControl}" onchange="desableCheckboxes(this.checked);"/>
				<rich:message errorClass="error" for="notControlFile" />	 			
	 		</td>
	 	</tr>
	 	<tr>
			<td style="width:330px">
				<h:outputLabel value="Posicionamento dos dados no arquivo:" style="color:green; font-weight:bold; font-size:11pt"/>
				<rich:menuSeparator/>
			</td>
		</tr>

	 	<tr>
	 		<td>
	 			<h:outputLabel value="Pontos: "/>
	 		</td>	
	 		<td>
				<h:outputLabel value="Col.: "/>
				<h:inputText id="colunaPontos" value="#{pontoBean.formato.colunaPonto}" maxlength="8" size="2">
					<f:validateLength maximum="10" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="colunaPontos" />	 		
	 		</td>
	 		<td style="display:none">
				<h:outputLabel value="Tam.: "/>
				<h:inputText id="tamanhoPontos" value="#{pontoBean.formato.tamanhoPonto}" maxlength="8" size="2">
					<f:validateLength maximum="10" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="tamanhoPontos" />	 		
	 		</td>
	 	</tr>
	 	<tr>	
	 		<td>
	 			<h:outputLabel value="Latitude: "/>
	 		</td>
	 		<td>
				<h:outputLabel value="Col.: "/>
				<h:inputText id="colunaLatitude" value="#{pontoBean.formato.colunaLatitude}" maxlength="8" size="2">
					<f:validateLength maximum="10" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="colunaLatitude" />	 		
	 		</td>
	 		<td style="display:none">
				<h:outputLabel value="Tam.: "/>
				<h:inputText id="tamanhoLatitude" value="#{pontoBean.formato.tamanhoLatitude}" maxlength="8" size="2">
					<f:validateLength maximum="10" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="tamanhoLatitude" />	 		
	 		</td>
	 	</tr>
	 	<tr>	
	 		<td>
	 			<h:outputLabel value="Longitude: "/>
	 		</td>
	 		<td>
				<h:outputLabel value="Col.: "/>
				<h:inputText id="colunaLongitude" value="#{pontoBean.formato.colunaLongitude}" maxlength="8" size="2">
					<f:validateLength maximum="10" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="colunaLongitude" />	 		
	 		</td>
	 		<td style="display:none">
				<h:outputLabel value="Tam.: "/>
				<h:inputText id="tamanhoLongitude" value="#{pontoBean.formato.tamanhoLatitude}" maxlength="8" size="2">
					<f:validateLength maximum="10" />
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message errorClass="error" for="tamanhoLongitude" />	 		
	 		</td>
		</tr>
		<tr>
			<td>
				<h:outputText styleClass="text" value="Salvar como pontos de clientes: " style="color:blue; font-size:10pt"/>
				<h:selectBooleanCheckbox styleClass="none" value="#{pontoBean.entity.statusMapa}"/>
			</td>		
		</tr>

	</table>
	<br/>

	<rich:tabPanel switchType="client"  immediate="true" >

		<rich:tab label="Importar Ponto">

			<h:panelGrid id="panelPontos" columns="5" styleClass="crud" columnClasses="label">

				<a4j:support event="onclick" action="#{pontoBean.populate}" reRender="caracterSeperador,caractereInicio,caracteresFim,colunaPontos,tamanhoPontos,colunaLatitude,tamanhoLatitude,colunaLongitude,tamanhoLongitude"/>
				<rich:fileUpload id="uploadPontos" validatorMessage="OK" fileUploadListener="#{pontoBean.saveImportPonto}" immediate="false" acceptedTypes="txt,xml,kml"
	            	maxFilesQuantity="1" clearControlLabel="Limpar" clearAllControlLabel="Limpar Todos" uploadControlLabel="Carregar"
	            	addControlLabel="Carregar Arquivo" doneLabel="Arquivo Enviado!" listHeight="90px">
					<f:facet name="label">
						<h:outputText value="{_KB}KB de {KB}KB enviados --- {mm}:{ss}"/>
	        		</f:facet>

	        		<a4j:support event="onuploadcomplete" action="#{pontoBean.populate}" oncomplete="sucesso('#{pontoBean.message}');" reRender="popup"/>

				</rich:fileUpload>

			</h:panelGrid>

		</rich:tab>

	</rich:tabPanel>

	<a4j:commandButton value="Voltar" type="submit" action="#{pontoBean.search}" styleClass="button" immediate="true" reRender="popup"/>

</ui:composition>